package com.xubeizhi.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xubeizhi.common.Result;
import com.xubeizhi.entity.User;
import com.xubeizhi.mapper.UserMapper;
import com.xubeizhi.service.UserService;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Override
    public Result login(User user) {
        String username = user.getUsername();
        String password = user.getPassword();

        User dto = baseMapper.selectUsernameAndPassword(username, password);
        if (dto.getUsername() == null){
            return Result.error(1,"帐号为空，请检查",null);
        }
        if (password.equals(dto.getPassword())){
            return Result.success(0,"登录成功",dto);
        }
        return Result.error(1,"密码错误",null);
    }
}
